<template>
    <div class="main">
        <mt-swipe :auto="2000">
             <mt-swipe-item v-for="(item,index) in iamg ">
                 <img :src="item.img" width="100%" height="100%"/>
             </mt-swipe-item>
        </mt-swipe>
        <div class="mui-slider-group">
            <div class="mui-slider-item">
                <ul class="mui-table-view mui-grid-view mui-grid-9">
                    <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4">
                        <router-link to="/supermarket">
                            <img src="./img/menu1.png" height="119" width="120"/>
                            <div class="mui-media-body">supermarket</div>
                        </router-link>
                    </li>
                    <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4">
                         <router-link to="/news">
                            <img src="./img/menu2.png" height="119" width="120"/>
                            <div class="mui-media-body">news</div>
                        </router-link>
                    </li>
                    <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4">
                        <a href="#">
                            <img src="./img/menu3.png" height="119" width="120"/>
                            <div class="mui-media-body">Chat</div>
                        </a>
                    </li>
                    <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4">
                        <a href="#">
                            <img src="./img/menu4.png" height="119" width="120"/>
                            <div class="mui-media-body">location</div>
                        </a>
                    </li>
                    <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4">
                        <a href="#">
                            <img src="./img/menu5.png" height="119" width="120"/>
                            <div class="mui-media-body">Search</div>
                        </a>
                    </li>
                    <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4">
                        <a href="#">
                            <img src="./img/menu6.png" height="119" width="120"/>
                            <div class="mui-media-body">Phone</div>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="row">
            <ul  v-for="(item,index) in list ">
                <li class="col-xs-6">
                    <router-link class="thumbnail" :to="'/particulars/'+item.id">
                        <img :src="item.img_url" height="580" width="580"/>
                        <div class="caption">
                            <h5 :title="item.title">{{item.title}}</h5>
                            <p><span style="text-decoration:line-through;">￥{{item.market_price}}</span>    
                            ￥{{item.sell_price}}</p>

                        </div>
                    </router-link>
                </li>
            </ul>
            <mt-button size="large" @click="getMore($event)">查看更多</mt-button>
        </div>
    </div>
</template>

<script>
    import mui from './../../dist/js/mui.js';

    export default {
     //全部挂载到dom里
      data(){
          return{
             
              pageindex:1,
              list:[],
              leg:[],
              iamg:[],
          }
        },
        methods:{
            getSlider(){
                    this.$http.get("api/getlunbo").then(
                    result=>{
                    if(result.body.status==0){
                      this.iamg=result.body.message;
                }else{
                        console.log("失败");
                    }
                })
            },
            get(){
                this.$http.get("api/getgoods?pageindex="+this.pageindex).then(
                    result=>{
                    if(result.body.status==0){
                       this.list=this.list.concat(result.body.message);
                        this.leg = result.body.message;
                    }else{
                        console.log("失败");
                    }
                })
            },
            
            getMore(e){
            this.pageindex++;
            this.get();
            // console.log(this.leg);
            if(this.leg.length==3){
                 var thisDom = e.currentTarget;
                 thisDom.hidden=true;
            }
           },
           
        },
         created:function(){
            this.get();
            this.getSlider();
        },
        mounted:function () {
            var slider = mui('#slider');
            slider.slider({
                interval: 1000,
            });
        }
    }

</script>

<style scoped lang="scss">
    .mint-swipe{
        height: 200px;
        overflow: hidden;
        text-align: center;
    }
     .mui-table-view-cell img{
        width: 50px;
        height: 50px;
    } 
    .main{
        margin-bottom: 70px;
    }
     ul{
        padding: 0px;
        margin-top: 10px;
    }
li{
    list-style: none;
    margin: 0px;
   
} 
h5{
        width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow:ellipsis;

    }

</style>